<?php
/**
 * Object Relational Persistence Mapping Class for table: PhaSequences
 *
 * @package	modules.dept_pharmacy.ordo
 * @author	viethd
 * @version $
 * @copyright 2009 LHV Company
 */
class PhaSequences extends ORDataObject {

	/**#@+
	 * Fields of table: pha_req_exticket_detail mapped to class members
	 */
	var $pha_sequences_id		= '';
	var $im_ticket_seq		= '';
	var $ex_ticket_seq		= '';
	var $req_ticket_seq		= '';
	
	/**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'pha_sequences';

	/**
	 * Primary Key
	 */
	var $_key = 'pha_sequences_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'PhaSequences';

	/**
	 * Handle instantiation
	 */
	function __construct() {
		parent::ORDataObject();
	}
	
	public function getImTicketSeq() {
	    $ds =& new Datasource_sql();
        $sql = array(
                    'cols'  => "im_ticket_seq",
                    'from'  => "$this->_table"
                    );
        $ds->setup($this->_db, $sql);
        $result = $ds->toArray();        
        if (empty($result)) {
            return 0;
        }
        return $result[0]['im_ticket_seq'];  
	    
	}
	
    public function incImTicketSeq() {
        $seq = $this->getImTicketSeq();
        $sql = "UPDATE $this->_table SET im_ticket_seq = " . ($seq + 1);
        $this->_execute($sql);        
    }
    
    public function getExTicketSeq() {
        $ds =& new Datasource_sql();
        $sql = array(
                    'cols'  => "ex_ticket_seq",
                    'from'  => "$this->_table"
                    );
        $ds->setup($this->_db, $sql);
        $result = $ds->toArray();        
        if (empty($result)) {
            return 0;
        }
        return $result[0]['ex_ticket_seq'];  
        
    }
    
    public function incExTicketSeq() {
        $seq = $this->getExTicketSeq();
        $sql = "UPDATE $this->_table SET ex_ticket_seq = " . ($seq + 1);
        $this->_execute($sql);        
    }
	
}
?>
